{extend name='base'}
{block name='content'}
<!--页面主要内容-->
<main class="lyear-layout-content">

    <div class="container-fluid">

        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <h4>课程列表</h4>
                    </div>
                    <div class="card-body">

                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>名称</th>
                                    <th>缩略图</th>
                                    <th>所属分类</th>
                                    <th>创建时间</th>
                                    <th width="150">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {foreach $artList as $v}
                                <tr>
                                    <td>{$v.art_id}</td>
                                    <td>{$v.art_name}</td>
                                    <td><img src="{$v.art_thumb}" style="width:40px;" onclick="openthumb('{$v.art_thumb}')" alt="点击查看大图"></td>
                                    <td>
                                        {if $v.art_type==1}
                                            政治文件
                                        {else/}
                                            考试资料
                                        {/if}
                                    </td>
                                    <td>{:date('Y-m-d',$v.art_creat_time)}</td>
                                    <td>
                                        <div class="btn-group">
                                            <a class="btn btn-xs btn-default" href="{:url('admin/article/edit',['id'=>$v.art_id])}" ><i class="mdi mdi-pencil"></i>编辑</a>
                                            <a class="btn btn-xs btn-default" onclick="del({$v.art_id})" ><i class="mdi mdi-window-close"></i>删除</a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}

                                </tbody>
                            </table>
                        </div>


                    </div>
                </div>
            </div>

        </div>

    </div>

</main>
<!--End 页面主要内容-->
<script>
    layui.use('layer', function(){
        var layer = layui.layer;

    };
</script>
<script>
    function openthumb(url){
        layer.open({
            title:"查看大图",
            type: 2,
            content: url,
            area: ['600px', '400px']
        });
    }
    function del(pro_id) {
        layer.confirm('您确定删除该咨询吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('/admin/article/delete',{"id":pro_id},function (res) {
                if(res.msg){
                    layer.msg('删除成功', {icon: 1});
                    window.location.reload()
                }else {
                    layer.msg('删除失败',{icon:2});
                }
            })
            //layer.msg('的确很重要', {icon: 1});
        });
    }


</script>
{/block}